Skip to main content

Socket Connection

In order to connect the user and the doctor there should be a channel that reflects the status update of the consultation, So we have the Pusher.

Pusher

For initiating the socket, there is a needed data, It is already included in the consultation data

import 'package:altibbi/pusher.dart';

Pusher().init(
onEvent: onEvent,
channelName: "pusher_channel_name", // retrun from the consultation api
apiKey: "pusher_api_key" // retrun from the consultation api
);

Use Pusher Service To Listen To Consultation Event Initializing the Pusher Service:

void onEvent(event) async {
print("event Name = " + event.eventName);
}

Next Step (Move to Consultation)

On listening to the events, the event call-status reflects the status of the consultation, So you need to check the consultation data on event listener and call getConsultationInfo to check the config of the consultation and once the consultation status is in_progress and the config is ready you can move to the consultation screen

For Chat consultation the data will include the chatConfig object For Voip consultations the data will include the voipConfig object For Video consultations the data will include the videoConfig object

Config Classes

class ChatConfig {
int? id;
int? consultationId;
String? groupId;
String? chatUserId;
String? appId;
String? chatUserToken;

ChatConfig({
this.id,
this.consultationId,
this.groupId,
this.appId,
this.chatUserId,
this.chatUserToken,
});
}

For Both, voipConfig and videoConfig

class VoipConfig {
int? id;
int? consultationId;
String? apiKey;
String? callId;
String? token;

VoipConfig({
this.id,
this.consultationId,
this.apiKey,
this.callId,
this.token,
});
}